<?php

namespace app\api\controller;

use think\Db;

class Patent extends Index
{
    /**
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     *匹配
     */
    public function mate()
    {
        $page = (isset($_GET['page']) && !empty($_GET['page'])) ? $_GET['page'] : 1;
        $name = (isset($_GET['name']) && !empty($_GET['name']) ? $_GET['name'] : null);

        $where['order'] = array('like', "%$name%");
        $field = "id,order,FMMC,TOTAL_COUNT";
        $res['data'] = Db::name('patent_b')->where($where)->field($field)->page($page)->limit(10)->select();
        $res['count'] = Db::name('patent_b')->where($where)->count();
        if (isset($res) || !empty($res)) {
            $this->_jsonp('200', '专利匹配查询成功', $res);
        } else {
            $this->_jsonp('1000', '专利匹配查询失败', null);
        }
    }

    /**
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * 匹配
     */
    public function mate_msg()
    {
        $where['id'] = trim(input('get.id'));
        $res = Db::name('patent_b')->where($where)->field('order,FMMC,TOTAL_COUNT')->find();
        if (isset($res) || !empty($res)) {
            $this->_jsonp('200', '专利匹配查询成功', $res);
        } else {
            $this->_jsonp('1000', '专利匹配查询失败', null);
        }
    }

    /**
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * 评分
     */
    public function manage()
    {
        $page = (isset($_GET['page']) && !empty($_GET['page'])) ? $_GET['page'] : 1;
        $name = (isset($_GET['name']) && !empty($_GET['name']) ? $_GET['name'] : null);

        $where['order'] = array('like', "%$name%");
        $field = "order,FMMC,id,ZIPC_TECH,total,P1,P2,P3,P4,P5,AVG_P";
        $res['data'] = Db::name('patent_a')->where($where)->field($field)->page($page)->limit(10)->select();
        $res['count'] = Db::name('patent_a')->where($where)->count();
        if (isset($res) || !empty($res)) {
            $this->_jsonp('200', '专利匹配查询成功', $res);
        } else {
            $this->_jsonp('1000', '专利匹配查询失败', null);
        }

    }

    /**
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * 评分
     */
    public function manage_msg()
    {
        $where['id'] = trim(input('get.id'));
        $res = Db::name('patent_a')->where($where)->field('order,FMMC,id,ZIPC_TECH,total,P1,P2,P3,P4,P5,AVG_P')->find();
        if (isset($res) || !empty($res)) {
            $this->_jsonp('200', '专利匹配查询成功', $res);
        } else {
            $this->_jsonp('1000', '专利匹配查询失败', null);
        }
    }
}